<?php
/**
 * Project: Recipe
 * File: SystemInfoAction.class.php
 * Author: Xnfy520@gmail.com
 * Date: 12-5-8
 * Time: 上午8:48
 */


class SystemInfoAction extends CommonAction{

	function index(){
		$this->display('systemset');
	}

	function systemset(){
		$this->display();
	}

	function modifysysteminfo(){
		$siteinfo = $_POST;
		$file = $siteinfo['filename'];
		if($file=="siteconfig.inc.php"){
			unset($siteinfo['filename']);
			unset($siteinfo['__hash__']);
			if($siteinfo['twitterlink']==''){$siteinfo['twitterlink']='www.twitter.com';};
			if($siteinfo['facebooklink']==''){$siteinfo['facebooklink']='www.facebook.com';};
			if($siteinfo['rsslink']==''){$siteinfo['rsslink']='www.rss.com';};
			if($siteinfo['sitename']==''){$siteinfo['sitename']='recipe';};
			if($siteinfo['pagenum']==''){$siteinfo['pagenum']='10';};
			if($siteinfo['contact']==''){$siteinfo['contact']='xnfy520';};
			if($siteinfo['phone']==''){$siteinfo['phone']='110';};
			if($siteinfo['address']==''){$siteinfo['address']='Wuhan';};
			if($siteinfo['copyright']==''){$siteinfo['copyright']='ICP证号：京ICP备11027992号 Copyright © 2003-2012 MEISHIJ CO.,LTD.';};
			$content = "<?php \n\n\treturn array(\n";
			foreach($siteinfo as $key=>$value){
				$key = strtoupper($key);
				if(!strtolower($value) || is_numeric($value)){
					$content.="\t'$key'=>$value,\n";
				}else{
					$content.="\t'$key'=>'$value',\n";
				}
			}
			$content.="\n);";
			$f = chmod($file, 0755);
			$put = file_put_contents($file, $content);
			if($put){
				$this->success('Modify System configuration success');

			}else{
				$this->error('Modify the configuration files of the system fail');
			}
		}else{
			$this->error('The configuration file does not exist');
		}
	}

}